
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>01-SpringBoot-Jar包转war包 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../" />
    
    
    <link rel="prev" href="../" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../">
            
                <a href="../">
            
                    
                    编辑器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../editortools/SublineText3-Quick-Key.html">
            
                <a href="../editortools/SublineText3-Quick-Key.html">
            
                    
                    SublineText3快捷键
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../editortools/SublineText3.html">
            
                <a href="../editortools/SublineText3.html">
            
                    
                    SublineText3问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../editortools/iTerm2-guide.html">
            
                <a href="../editortools/iTerm2-guide.html">
            
                    
                    iTerm2指南
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../">
            
                <a href="../">
            
                    
                    乱七八糟
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../sundry/git-note.html">
            
                <a href="../sundry/git-note.html">
            
                    
                    Git 简单笔记
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../sundry/gitbook-doc.html">
            
                <a href="../sundry/gitbook-doc.html">
            
                    
                    gitbook 教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../sundry/gitbook-to-github.html">
            
                <a href="../sundry/gitbook-to-github.html">
            
                    
                    gitbook 集成到Github
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../sundry/git-integrate.html">
            
                <a href="../sundry/git-integrate.html">
            
                    
                    Git提速
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../sundry/markdown-doc.html">
            
                <a href="../sundry/markdown-doc.html">
            
                    
                    markdown 语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="../sundry/maven-nexus.html">
            
                <a href="../sundry/maven-nexus.html">
            
                    
                    Maven 私服搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="../sundry/idea-config.html">
            
                <a href="../sundry/idea-config.html">
            
                    
                    IDEA 配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="../sundry/idea-quick-key.html">
            
                <a href="../sundry/idea-quick-key.html">
            
                    
                    IDEA 快捷键
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="../sundry/iterm2.html">
            
                <a href="../sundry/iterm2.html">
            
                    
                    iTerm2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" >
            
                <a target="_blank" href="http://fontawesome.dashgame.com/">
            
                    
                    Font Awesome字体
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../">
            
                <a href="../">
            
                    
                    mariadb
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../mariadb/mariadb-install.html">
            
                <a href="../mariadb/mariadb-install.html">
            
                    
                    mariadb 安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../mariadb/mysql-install.html">
            
                <a href="../mariadb/mysql-install.html">
            
                    
                    mysql 安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../mariadb/mysql-base.html">
            
                <a href="../mariadb/mysql-base.html">
            
                    
                    mysql 基础知识
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../">
            
                <a href="../">
            
                    
                    MongoDB
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../mongodb/mongodb-install.html">
            
                <a href="../mongodb/mongodb-install.html">
            
                    
                    MongoDB 安装
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../">
            
                <a href="../">
            
                    
                    nginx
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../nginx/nginx-install.html">
            
                <a href="../nginx/nginx-install.html">
            
                    
                    Nginx 安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../nginx/nginx-commandline.html">
            
                <a href="../nginx/nginx-commandline.html">
            
                    
                    Ngixn 命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../nginx/nginx-virtualhost.html">
            
                <a href="../nginx/nginx-virtualhost.html">
            
                    
                    Nginx 虚拟主机
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../">
            
                <a href="../">
            
                    
                    HttpClient
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../httpclient/httpclient-timeout.html">
            
                <a href="../httpclient/httpclient-timeout.html">
            
                    
                    HttpClient几个超时
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../httpclient/httpclient-pool.html">
            
                <a href="../httpclient/httpclient-pool.html">
            
                    
                    HttpClient 连接池
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../">
            
                <a href="../">
            
                    
                    Java
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../java/001-tomcat-loader-cpu-high.html">
            
                <a href="../java/001-tomcat-loader-cpu-high.html">
            
                    
                    01-Tomcat应用负载过高—CPU过高
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../">
            
                <a href="../">
            
                    
                    Spring与SpringBoot
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.9.1" data-path="001-SpringBoot-form-jar-to-war.html">
            
                <a href="001-SpringBoot-form-jar-to-war.html">
            
                    
                    01-SpringBoot-Jar包转war包
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../">
            
                <a href="../">
            
                    
                    RPC
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../rpc/thrift/thrift-01-intro.html">
            
                <a href="../rpc/thrift/thrift-01-intro.html">
            
                    
                    01-Thrift简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../rpc/thrift/thrift-02-install.html">
            
                <a href="../rpc/thrift/thrift-02-install.html">
            
                    
                    02-Thrift安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../rpc/thrift/thrift-03-types.html">
            
                <a href="../rpc/thrift/thrift-03-types.html">
            
                    
                    03-Thrift数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../rpc/thrift/thrift-04-generated-code.html">
            
                <a href="../rpc/thrift/thrift-04-generated-code.html">
            
                    
                    04-Thrift代码生成
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../rpc/thrift/thrift-05-architecture.html">
            
                <a href="../rpc/thrift/thrift-05-architecture.html">
            
                    
                    05-Thrift架构设计
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../">
            
                <a href="../">
            
                    
                    线程世界
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../thread/01-traditional-thread.html">
            
                <a href="../thread/01-traditional-thread.html">
            
                    
                    01-传统线程技术
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../thread/02-traditional-mutex.html">
            
                <a href="../thread/02-traditional-mutex.html">
            
                    
                    02-线程之间的互斥
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../thread/03-traditional-communication.html">
            
                <a href="../thread/03-traditional-communication.html">
            
                    
                    03-线程之间的通信
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../thread/04-traditional-thread-state.html">
            
                <a href="../thread/04-traditional-thread-state.html">
            
                    
                    04-线程状态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../thread/05-traditional-thread-join.html">
            
                <a href="../thread/05-traditional-thread-join.html">
            
                    
                    05-线程join方法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../">
            
                <a href="../">
            
                    
                    Linux
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../linux/001-linux-command.html">
            
                <a href="../linux/001-linux-command.html">
            
                    
                    01-Linux常用命令总结
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../linux/002-linux-firewall.html">
            
                <a href="../linux/002-linux-firewall.html">
            
                    
                    02-Linux防火墙
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../linux/003-linux-tmux.html">
            
                <a href="../linux/003-linux-tmux.html">
            
                    
                    03-Linux-Tmux
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../">
            
                <a href="../">
            
                    
                    数据结构与算法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../datastructure/01-intro.html">
            
                <a href="../datastructure/01-intro.html">
            
                    
                    01-简介
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../">
            
                <a href="../">
            
                    
                    前端
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="../front/01-yarn.html">
            
                <a href="../front/01-yarn.html">
            
                    
                    01-yarn
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="../front/02-jsx.html">
            
                <a href="../front/02-jsx.html">
            
                    
                    02-jsx语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.3" data-path="../front/03-react-component.html">
            
                <a href="../front/03-react-component.html">
            
                    
                    03-React组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.4" data-path="../front/04-ES6.html">
            
                <a href="../front/04-ES6.html">
            
                    
                    04-ES6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.5" data-path="../front/05-webpack.html">
            
                <a href="../front/05-webpack.html">
            
                    
                    05-webpack
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >01-SpringBoot-Jar包转war包</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="springboot-&#x6709;-jar-&#x6539;&#x6210;-war-&#x90E8;&#x7F72;">SpringBoot &#x6709; jar &#x6539;&#x6210; war &#x90E8;&#x7F72;</h1>
<p>&#x672C;&#x6587;&#x662F;&#x57FA;&#x4E8E; SpringBoot 2.0 &#x4EE5;&#x4E0A;&#x7248;&#x672C;&#x3002;&#x6CE8;&#x610F;&#xFF0C;SpringBoot 2.0 &#x9700;&#x8981; Tomcat 8.5 &#x4EE5;&#x4E0A;&#x7248;&#x672C;&#x3002;</p>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;SpringBoot &#x662F;&#x6253;&#x6210; jar &#x5305;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x6709;&#x4EBA;&#x53EF;&#x80FD;&#x66F4;&#x559C;&#x6B22;&#x6253;&#x6210; war &#x90E8;&#x7F72;&#x5230; Tomcat &#x6216;&#x5176;&#x4ED6; Servlet &#x5BB9;&#x5668;&#x4E2D;&#x3002;</p>
<p>SpringBoot &#x6709; jar &#x6539;&#x6210; war &#x5927;&#x7EA6;&#x6709;&#x5982;&#x4E0B;&#x6B65;&#x9AA4;&#xFF1A;</p>
<blockquote>
<ol>
<li>&#x4FEE;&#x6539; pom.xml &#x6587;&#x4EF6;&#xFF0C;&#x5C06; jar &#x6539;&#x6210; war</li>
<li>&#x6392;&#x9664;&#x5185;&#x7F6E;&#x7684; Tomcat &#x5BB9;&#x5668;&#xFF0C;&#x5E76;&#x6DFB;&#x52A0;&#x4F9D;&#x8D56; spring-boot-starter-tomcat&#xFF0C;&#x4F7F;&#x5176; scope &#x4E3A; provided&#x3002;</li>
<li>&#x542F;&#x52A8;&#x7C7B;&#x7EE7;&#x627F; SpringBootServletInitializer</li>
<li>&#x6253;&#x5305;&#x90E8;&#x7F72;   </li>
</ol>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x4F60;&#x7684;&#x5E94;&#x7528;&#x53EF;&#x80FD;&#x662F;&#x5355;&#x5E94;&#x7528;&#xFF0C;&#x4E5F;&#x53EF;&#x80FD;&#x662F;&#x7531;&#x591A; Module &#x7EC4;&#x5408;&#x800C;&#x6210;&#x7684;&#x3002;&#x4E24;&#x79CD;&#x4E0D;&#x540C;&#x7ED3;&#x6784;&#x7684;&#x5E94;&#x7528;&#x914D;&#x7F6E;&#x7A0D;&#x6709;&#x5DEE;&#x522B;&#x3002;</p>
</blockquote>
<p>&#x5982;&#x679C;&#x4F60;&#x7684;&#x5E94;&#x7528;&#x7528;&#x5230;&#x4E86; Maven&#xFF0C;&#x90A3;&#x4E48;&#x4F60;&#x7684;&#x5E94;&#x7528;&#x53EF;&#x80FD;&#x662F;&#x5206;&#x5C42;&#x642D;&#x5EFA;&#x7684;&#xFF0C;&#x5982;&#xFF0C;platform-parent&#xFF0C;platform-base&#xFF08;&#x516C;&#x5171;&#x4EE3;&#x7801;&#xFF09;&#xFF0C;platform-dao&#xFF0C;platform-service&#xFF0C;platform-web&#x3002;&#x4E0D;&#x540C;&#x7684;&#x5C42;&#x6B21;&#x4EE3;&#x8868;&#x4E0D;&#x540C;&#x7684; Module&#xFF0C;&#x719F;&#x6089; Web &#x5F00;&#x53D1;&#x7684;&#x540C;&#x5B66;&#x5E94;&#x8BE5;&#x4E86;&#x89E3;&#x8FD9;&#x79CD;&#x7ED3;&#x6784;&#x3002;&#x4E3A;&#x4E86;&#x7B80;&#x5316;&#xFF0C;&#x6B64;&#x5904;&#x4EC5;&#x4EE5; platform-parent&#xFF0C;platform-base&#xFF0C;platform-web &#x4E3A;&#x4F8B;&#xFF0C;&#x5373; platform-web &#x5305;&#x62EC; Dao &#x548C; Service&#x3002;</p>
<h4 id="1-&#x4FEE;&#x6539;-pomxml-&#x6587;&#x4EF6;&#xFF0C;&#x5C06;-jar-&#x6539;&#x6210;-war">1. &#x4FEE;&#x6539; pom.xml &#x6587;&#x4EF6;&#xFF0C;&#x5C06; jar &#x6539;&#x6210; war</h4>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">packaging</span>&gt;</span>war<span class="hljs-tag">&lt;/<span class="hljs-name">packaging</span>&gt;</span>
</code></pre>
<p>&#x5982;&#x679C;&#x662F;&#x591A; Module &#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x53EA;&#x662F;&#x5C06; <strong>platform-web</strong> &#x7684; jar &#x6539;&#x6210; war &#x5373;&#x53EF;&#x3002;</p>
<h4 id="2-&#x6392;&#x9664;&#x5185;&#x7F6E;&#x7684;-tomcat-&#x5BB9;&#x5668;&#xFF0C;&#x5E76;&#x6DFB;&#x52A0;&#x4F9D;&#x8D56;-spring-boot-starter-tomcat&#xFF0C;&#x4F7F;&#x5176;-scope-&#x4E3A;-provided&#x3002;">2. &#x6392;&#x9664;&#x5185;&#x7F6E;&#x7684; Tomcat &#x5BB9;&#x5668;&#xFF0C;&#x5E76;&#x6DFB;&#x52A0;&#x4F9D;&#x8D56; spring-boot-starter-tomcat&#xFF0C;&#x4F7F;&#x5176; scope &#x4E3A; provided&#x3002;</h4>
<p>&#x4FEE;&#x6539; pom.xml &#x6DFB;&#x52A0;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- &#x6392;&#x9664;&#x5185;&#x7F6E;&#x7684; Tomcat &#x5BB9;&#x5668; --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.boot<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-boot-starter-web<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">exclusions</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">exclusion</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.boot<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-boot-starter-tomcat<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">exclusion</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">exclusions</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
<span class="hljs-comment">&lt;!-- &#x6DFB;&#x52A0; spring-boot-starter-tomcat &#x4F7F;&#x5176; scope &#x4E3A; provided --&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.boot<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-boot-starter-tomcat<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">scope</span>&gt;</span>provided<span class="hljs-tag">&lt;/<span class="hljs-name">scope</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<p>&#x5982;&#x679C;&#x662F;&#x591A; Module &#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x6392;&#x9664;&#x5185;&#x7F6E;&#x7684; Tomcat &#x5BB9;&#x5668;&#xFF0C;&#x662F;&#x5728; platform-base &#x4E0B;&#x9762;&#x7684; POM.xml &#x6587;&#x4EF6;&#xFF0C;&#x800C;&#x6DFB;&#x52A0; spring-boot-starter-tomcat 
&#x4F9D;&#x8D56;&#x662F;&#x5728; platform-web &#x4E0B;&#x9762;&#x7684; POM.xml &#x4E2D;&#x3002;</p>
<h4 id="3-&#x542F;&#x52A8;&#x7C7B;&#x7EE7;&#x627F;-springbootservletinitializer">3. &#x542F;&#x52A8;&#x7C7B;&#x7EE7;&#x627F; SpringBootServletInitializer</h4>
<pre><code class="lang-java"><span class="hljs-keyword">import</span> org.springframework.boot.SpringApplication;
<span class="hljs-keyword">import</span> org.springframework.boot.autoconfigure.SpringBootApplication;
<span class="hljs-keyword">import</span> org.springframework.boot.builder.SpringApplicationBuilder;
<span class="hljs-keyword">import</span> org.springframework.boot.web.support.SpringBootServletInitializer;

<span class="hljs-meta">@SpringBootApplication</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SpringBootWebApplication</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">SpringBootServletInitializer</span> </span>{

    <span class="hljs-comment">// &#x76F8;&#x5F53;&#x4E8E; WEB-INF/web.xml</span>
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">protected</span> SpringApplicationBuilder <span class="hljs-title">configure</span><span class="hljs-params">(SpringApplicationBuilder application)</span></span>{         
        <span class="hljs-keyword">return</span> application.sources(SpringBootWebApplication.class);
    }

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> <span class="hljs-keyword">throws</span> Exception </span>{
        SpringApplication.run(SpringBootWebApplication.class, args);
    }
}
</code></pre>
<p>Spring Boot &#x4E4B;&#x6240;&#x4EE5;&#x80FD;&#x591F;&#x6253;&#x5305;&#x6210;&#x4E00;&#x4E2A;&#x53EF;&#x6267;&#x884C;&#x7684; jar &#x5305;&#xFF0C;&#x5B8C;&#x5168;&#x662F;&#x4F9D;&#x8D56; Maven &#x7684;&#x4E00;&#x4E2A;&#x63D2;&#x4EF6; spring-boot-maven-plugin&#x3002;<br>&#x5982;&#x679C;&#x5C06; Spring Boot &#x9879;&#x76EE;&#x7531; jar &#x5305;&#x8F6C;&#x6362;&#x6210; war&#x5305;&#xFF0C;&#x8F6C;&#x6362;&#x6210;&#x7684; war &#x5305;&#x65E2;&#x53EF;&#x4EE5;&#x50CF;&#x4F20;&#x7EDF;&#x9879;&#x76EE;&#x90A3;&#x6837;&#xFF0C;&#x5C06; war &#x5305;&#x653E;&#x5230; Tomcat &#x91CC;&#x9762;&#x542F;&#x52A8;&#x8FD0;&#x884C;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x50CF;&#x53EF;&#x6267;&#x884C; jar &#x5305;&#x4E00;&#x6837;&#xFF0C;&#x4F7F;&#x7528; <code>java -jar platform-web.war</code> &#x6765;&#x542F;&#x52A8;&#x9879;&#x76EE;&#xFF0C;&#x6B64;&#x65F6;&#x7684; war &#x5305;&#x65E2;&#x53EF;&#x4EE5;&#x8131;&#x79BB; Tomcat &#x72EC;&#x7ACB;&#x8FD0;&#x884C;&#xFF0C;&#x53C8;&#x53EF;&#x4EE5;&#x90E8;&#x7F72;&#x5230; Tomcat &#x5BB9;&#x5668;&#x91CC;&#x9762;&#x8FD0;&#x884C;&#x3002;  </p>
<p>&#x5148;&#x8BF4;&#x7B2C;&#x4E8C;&#x79CD;&#x60C5;&#x51B5;&#xFF0C;&#x5373;&#x751F;&#x6210;&#x7684; war &#x5305;&#x5373;&#x53EF;&#x72EC;&#x7ACB;&#x8FD0;&#x884C;&#xFF0C;&#x53C8;&#x80FD;&#x50CF;&#x4F20;&#x7EDF;&#x9879;&#x76EE;&#x4E00;&#x6837;&#x90E8;&#x7F72;&#x5230; Tomcat &#x91CC;&#x9762;&#x8FD0;&#x884C;&#x3002;  </p>
<ul>
<li>&#x9996;&#x5148;&#xFF0C;&#x542F;&#x52A8;&#x7C7B;&#x5FC5;&#x987B;&#x6709; main &#x65B9;&#x6CD5;&#x3002;</li>
<li>&#x7B2C;&#x4E8C;&#xFF0C;&#x5C31;&#x662F; <strong>platform-web</strong> &#x5FC5;&#x987B;&#x6709; spring-boot-maven-plugin &#x7684;&#x63D2;&#x4EF6;&#x3002;  </li>
</ul>
<p>&#x63D2;&#x4EF6;&#x914D;&#x7F6E;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">build</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">plugins</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">plugin</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.boot<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-boot-maven-plugin<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">configuration</span>&gt;</span>
                <span class="hljs-comment">&lt;!-- &#x9879;&#x76EE;&#x4E2D;&#x7684;&#x542F;&#x52A8;&#x7C7B; --&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">mainClass</span>&gt;</span>com.javaliu.boot.App<span class="hljs-tag">&lt;/<span class="hljs-name">mainClass</span>&gt;</span>
            <span class="hljs-tag">&lt;/<span class="hljs-name">configuration</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">plugin</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">plugins</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">build</span>&gt;</span>
</code></pre>
<p>&#x6B64;&#x65F6;&#x6253;&#x6210; war &#x5305;&#x7684;&#x6587;&#x4EF6;&#x7ED3;&#x6784;&#x5982;&#x56FE;&#xFF1A;</p>
<p><img src="images/execute-war.png" alt="&#x53EF;&#x6267;&#x884C;&#x7684;war&#x5305;"><br><img src="images/execute-war-embed-tomcat.png" alt="&#x53EF;&#x6267;&#x884C;&#x7684;war&#x5305;&#x5185;&#x7F6E;Tomcat"><br>&#x7531;&#x56FE;&#x53EF;&#x77E5;&#xFF0C;&#x53EF;&#x6267;&#x884C;&#x7684; war &#x5305;&#x62E5;&#x6709;&#x4E00;&#x4E9B;&#x800C;&#x5916;&#x7684;&#x7C7B;&#x548C;&#x5185;&#x7F6E;&#x7684; Tomcat &#x5BB9;&#x5668;&#x3002;</p>
<p>&#x5982;&#x679C;&#x662F;&#x7B2C;&#x4E00;&#x79CD;&#x60C5;&#x51B5;&#xFF0C;&#x5373;&#x4F20;&#x7EDF;&#x7684; war &#x9879;&#x76EE;&#xFF0C;&#x53EA;&#x80FD;&#x90E8;&#x7F72;&#x5728; Tomcat &#x4E2D;&#x8FD0;&#x884C;&#x3002;   </p>
<ul>
<li>&#x9996;&#x5148;&#xFF0C;&#x5220;&#x9664; spring-boot-maven-plugin &#x63D2;&#x4EF6;&#x7684;&#x914D;&#x7F6E;&#x3002;</li>
<li>&#x7B2C;&#x4E8C;&#xFF0C;&#x5220;&#x9664;&#x6389;&#x542F;&#x52A8;&#x7C7B;&#x7684; main &#x65B9;&#x6CD5;&#x3002;</li>
</ul>
<p>&#x6B64;&#x65F6;&#x6253;&#x6210;&#x7684; war &#x5305;&#x6587;&#x4EF6;&#x7ED3;&#x6784;&#x5982;&#x4E0B;&#xFF1A;</p>
<p><img src="images/traditional-war.png" alt="&#x4F20;&#x7EDF;&#x7684;war&#x5305;"><br><img src="images/traditional-war-no-tomcat.png" alt="&#x4F20;&#x7EDF;&#x7684;war&#x5305;&#x65E0;Tomcat">  </p>
<p>&#x4F20;&#x7EDF;&#x7684; war &#x5305;&#x6CA1;&#x6709;&#x989D;&#x5916;&#x7684;&#x7C7B;&#x6587;&#x4EF6;&#x4EE5;&#x53CA;&#x5185;&#x7F6E;&#x7684; Tomcat &#x5BB9;&#x5668;&#x3002;</p>
<p>&#x7531;&#x6B64;&#x53EF;&#x77E5;&#xFF0C;spring-boot-maven-plugin &#x63D2;&#x4EF6;&#x7684;&#x4F5C;&#x7528;&#x5C31;&#x662F;&#x5C06; Spring Boot &#x9879;&#x76EE;&#x6253;&#x5305;&#x6210;&#x53EF;&#x6267;&#x884C;&#x7684; jar &#x6216;&#x8005; war&#xFF0C;&#x5E76;&#x5C06; Tomcat &#x5185;&#x7F6E;&#x5230;&#x5E94;&#x7528;&#x4E2D;&#xFF0C;&#x4ECE;&#x800C;&#x5B9E;&#x73B0;&#x72EC;&#x7ACB;&#x90E8;&#x7F72;&#x3002;</p>
<h4 id="4-&#x6253;&#x5305;&#x90E8;&#x7F72;">4. &#x6253;&#x5305;&#x90E8;&#x7F72;</h4>
<p>&#x6839;&#x636E;&#x4E0D;&#x540C;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x6253;&#x5305;&#x90E8;&#x7F72;&#x7684;&#x60C5;&#x51B5;&#x4E5F;&#x4E0D;&#x540C;&#x3002;</p>
<ol>
<li><p>&#x53EF;&#x6267;&#x884C; war &#x5305;</p>
<ul>
<li>&#x4F7F;&#x7528; main &#x65B9;&#x6CD5;&#x542F;&#x52A8;&#x3002;</li>
<li>&#x4F7F;&#x7528; <code>spring-boot:run</code> &#x547D;&#x4EE4;&#x542F;&#x52A8;</li>
<li>&#x4F7F;&#x7528;&#x4F20;&#x7EDF; war &#x5305;&#x7684;&#x5F62;&#x5F0F;&#x542F;&#x52A8;</li>
</ul>
</li>
<li><p>&#x4F20;&#x7EDF; war &#x5305;</p>
<pre><code class="lang-shell">mvn clean package
</code></pre>
<p>&#x5C06;&#x6253;&#x51FA;&#x7684; war &#x6587;&#x4EF6;&#xFF0C;&#x5373; /target/xxxx-version.war &#x6587;&#x4EF6;&#x4E0A;&#x4F20;&#x5230;&#x6307;&#x5B9A;&#x7684; tomcat &#x542F;&#x52A8;&#x5373;&#x53EF;&#x3002;</p>
</li>
</ol>
<p><strong>&#x53C2;&#x8003;&#x8D44;&#x6599;</strong></p>
<p><a href="https://docs.spring.io/spring-boot/docs/2.0.1.RELEASE/reference/htmlsingle/#howto-create-a-deployable-war-file" target="_blank">https://docs.spring.io/spring-boot/docs/2.0.1.RELEASE/reference/htmlsingle/#howto-create-a-deployable-war-file</a></p>
<p><a href="https://www.mkyong.com/spring-boot/spring-boot-deploy-war-file-to-tomcat/" target="_blank">https://www.mkyong.com/spring-boot/spring-boot-deploy-war-file-to-tomcat/</a></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../" class="navigation navigation-prev " aria-label="Previous page: Spring与SpringBoot">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../" class="navigation navigation-next " aria-label="Next page: RPC">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"01-SpringBoot-Jar包转war包","level":"1.9.1","depth":2,"next":{"title":"RPC","level":"1.10","depth":1,"path":"README.md","ref":"README.md","articles":[{"title":"01-Thrift简介","level":"1.10.1","depth":2,"path":"rpc/thrift/thrift-01-intro.md","ref":"rpc/thrift/thrift-01-intro.md","articles":[]},{"title":"02-Thrift安装","level":"1.10.2","depth":2,"path":"rpc/thrift/thrift-02-install.md","ref":"rpc/thrift/thrift-02-install.md","articles":[]},{"title":"03-Thrift数据类型","level":"1.10.3","depth":2,"path":"rpc/thrift/thrift-03-types.md","ref":"rpc/thrift/thrift-03-types.md","articles":[]},{"title":"04-Thrift代码生成","level":"1.10.4","depth":2,"path":"rpc/thrift/thrift-04-generated-code.md","ref":"rpc/thrift/thrift-04-generated-code.md","articles":[]},{"title":"05-Thrift架构设计","level":"1.10.5","depth":2,"path":"rpc/thrift/thrift-05-architecture.md","ref":"rpc/thrift/thrift-05-architecture.md","articles":[]}]},"previous":{"title":"Spring与SpringBoot","level":"1.9","depth":1,"path":"README.md","ref":"README.md","articles":[{"title":"01-SpringBoot-Jar包转war包","level":"1.9.1","depth":2,"path":"SpringBoot/001-SpringBoot-form-jar-to-war.md","ref":"SpringBoot/001-SpringBoot-form-jar-to-war.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["toggle-chapters"],"pluginsConfig":{"toggle-chapters":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"SpringBoot/001-SpringBoot-form-jar-to-war.md","mtime":"2019-09-08T13:54:11.871Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-12-17T05:25:43.709Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

